package com.teaut.dota.hider.entity;

import com.teaut.dota.hider.entity.common.AbstractBaseEntity;
import com.teaut.dota.hider.entity.common.Tenant;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@Entity
@Table(name = "role_entity")
public class RoleEntity extends AbstractBaseEntity {

    private String name;
    private String description;

    @ManyToMany
    @JoinTable(name = "role_user_rela",// foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT), inverseForeignKey =@ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT),
            joinColumns = {@JoinColumn(name = "role_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))},
            inverseJoinColumns = {@JoinColumn(name = "user_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))}
    )
    public List<UserEntity> users;

    @ManyToMany
    @JoinTable(name = "role_menu_rela",// foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT), inverseForeignKey =@ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT),
            joinColumns = {@JoinColumn(name = "role_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))},
            inverseJoinColumns = {@JoinColumn(name = "menu_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))}
    )
    public List<MenuEntity> menus;
}